package com.lanchewuyou.user.driver.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanchewuyou.user.driver.R;
import com.lanchewuyou.user.driver.bean.OrderNoItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 易理赔未完成订单列表适配器
 */
public class OrderNoAdapter extends BaseAdapter {
    private List<OrderNoItem> orderNoItemList = new ArrayList<>();
    private LayoutInflater inflater;

    public OrderNoAdapter(List<OrderNoItem> orderNoItemList, Context mContext) {
        this.orderNoItemList = orderNoItemList;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return orderNoItemList.size();
    }

    @Override
    public Object getItem(int position) {
        return orderNoItemList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        OrderNoItem orderNoItem = orderNoItemList.get(position);
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = inflater.inflate(R.layout.order_no_item, null);
            viewHolder.orderNoCaseType = (TextView) convertView.findViewById(R.id.order_no_case_type);
            viewHolder.orderNoCaseTime = (TextView) convertView.findViewById(R.id.order_no_case_time);
            viewHolder.orderNoCaseAdd = (TextView) convertView.findViewById(R.id.order_no_case_add);
            viewHolder.orderNoPayType = (TextView) convertView.findViewById(R.id.order_no_pay_type);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.orderNoCaseType.setText(orderNoItem.getType());
        viewHolder.orderNoCaseTime.setText(orderNoItem.getTime());
        viewHolder.orderNoCaseAdd.setText(orderNoItem.getAddress());
        viewHolder.orderNoPayType.setText(orderNoItem.getPayType());

        return convertView;
    }

    class ViewHolder {
        public TextView orderNoCaseType;
        public TextView orderNoCaseTime;
        public TextView orderNoCaseAdd;
        public TextView orderNoPayType;
    }
}
